package com.anita.member.domain.model;

import lombok.Getter;

/**
 * 性别枚举类
 * @author qiu
 * @date 2025/10/17
 * @description
 */
@Getter
public enum Gender {
    MALE(1,"男"),
    FEMALE(2,"女");

    private final int code;
    private final String desc;

    Gender(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int code() {
        return code;
    }

    public String desc() {
        return desc;
    }

    public static Gender of(int code) {
        for (Gender gender : values()) {
            if (gender.code == code) {
                return gender;
            }
        }
        throw new IllegalArgumentException("无效的性别代码: " + code);
    }
}
